package com.ctgu.examonline.controller;


import com.ctgu.examonline.entity.Problem;
import com.ctgu.examonline.service.ProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/problem")
public class ProblemController {

    @Autowired
    private ProblemService problemService;

    //查询所有试题
    @RequestMapping("/list")
    public List<Problem> list(){
        return problemService.listProblem();
    }

    //保存试题
    @RequestMapping("/add")
    public String save(Problem problem){
//        problemService.save(new Problem("在下列的 HTML 中，哪个是最大的标题？", null, "html",
//                1, "2", "计算机", "文件系统", 20001009));
        if(problem != null) {
            return "ok";
        }else {
            return "false";
        }
    }

    //删除
    @RequestMapping("/remove")
    public String remove(Integer pro_no){
//        problemService.remove(40006001);
        if(pro_no != null) {
            return "ok";
        }else {
            return "false";
        }
    }

    //更新
    @RequestMapping("/update")
    public String update(Problem problem){
//        problemService.update(new Problem(40006001,"在下列的 HTML 中，哪个是最大的标题？", null, "html",
//                1, "2", "概述", "文件系统", 20001009));
        if(problem != null) {
            return "update";
        }else {
            return "false";
        }
    }
}
